class Solution {
public:
    vector<vector<string>> groupAnagrams(vector<string>& strs) {
        vector<vector<string>> ret;
        unordered_map<string, vector<string>> m;
        for (auto& str : strs)
        {
            string st = str;
            sort(st.begin(), st.end());
            m[st].emplace_back(str);
        }
        for (auto& vm : m)
        {
            ret.emplace_back(vm.second);
        }
        return ret;
    }
};